$(document).ready(function(){
  
}); 
button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCK40","query");
}
/*
  点击新增按钮后调用后台的service
*/
button_insert_onclick = function () {
	var grid=isSelected("ef_grid_r");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	var date1;
	var date2;
	for(var i=0;i<rows.length;i++)
	{
		 date1=grid.getCellValueByColumnName(rows[i],"fdBeginDate");
	     date2=grid.getCellValueByColumnName(rows[i],"fdEndDate");
		if (date1 > date2){
			EFAlert("结束日期不能小于起始日期");
			return;
	}
	}
	
	efgrid.submitForm( "ef_grid_r", "ZM","ZMCK40","insert",true);
}
	

button_update_onclick = function() {
	var grid=isSelected("ef_grid_r");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	var date1;
	var date2;
	for(var i=0;i<rows.length;i++)
	{
		 date1=grid.getCellValueByColumnName(rows[i],"fdBeginDate");
	     date2=grid.getCellValueByColumnName(rows[i],"fdEndDate");
		if (date1 > date2){
			EFAlert("结束日期不能小于起始日期");
			return;
	}
	}
	efgrid.submitForm( "ef_grid_r", "ZM","ZMCK40","update",true);
}
//button_generate_onclick = function() {
//	var grid=isSelected("ef_grid_r");
//	if (grid == 0){
//		return; 
//	}
//	efgrid.submitForm( "ef_grid_r", "ZM","ZMCK40","generate",true);
//}

button_delete_onclick = function (){
//	if (isLegal() == 0) {
//        return;
//    }
	var grid=isSelected("ef_grid_r");
	if (grid == 0){
		return; 
	}
		
	efgrid.submitForm( "ef_grid_r", "ZM","ZMCK40","delete",true);
}

button_report_onclick = function (){
//	if (isLegal() == 0) {
//        return;
//    }
	var grid=isSelected("ef_grid_r");
	if (grid == 0){
		return; 
	}
		

	efgrid.submitForm( "ef_grid_r", "ZM","ZMCK40","report",true);
}
//efgrid_afterAddNewRow = function(grid_id){
//	var userId=$('#userId').val();
//	var userName=$('#userName').val();
//	var departmentId=$('#departmentId').val();
//	var departmentName=$('#departmentName').val();
//	
//	var grid = efgrid.getGridObject(grid_id);
//	var rows = grid.getCheckedRows();
//	if(grid_id=="ef_grid_r")
//	{
//		for(var i = 0 ; i < rows.length;i++){
//			grid.setCellValue(rows[i],3,userName,TYPE_DATA);
//			grid.setCellValue(rows[i],5,userId,TYPE_DATA);
//			grid.setCellValue(rows[i],6,departmentName,TYPE_DATA);
//			grid.setCellValue(rows[i],7,departmentId,TYPE_DATA);
//		}
//	}
//}
